// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class sample102 : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        sourceCode.Text = @"public void LinqToEntities66()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;var query = from c in context.Customers<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;group c by c.Region into regions<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select new { region = regions.Key, count = regions.Count() };<br><br>&nbsp;&nbsp;&nbsp;&nbsp;ObjectDumper.Write(query);<br>}<br>";
    }

    public void ExecuteQuery(object src, EventArgs e)
    {
        using (context = new EntityNorthwind.EntityNorthwindContext(connstr))
        {
            LinqToEntities66();
        }
        this.output.Text = QueryOutput();
    }

	public void LinqToEntities66()
{
    var query = from c in context.Customers
                group c by c.Region into regions
                select new { region = regions.Key, count = regions.Count() };

    ObjectDumper.Write(query);
}

}
